<?php


namespace designpatterns\observer\other;


use designpatterns\observer\Observer;

class User implements Observer
{
    private $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function update($news)
    {
        echo "{$this->name}收到新闻通知：{$news}"."<br>";
    }


    /**
     * @param array{product_id:string,id:int} $array
     * @return array{info:array}
     */
    public function test(array $array) : array
    {
        return ['info' => $array];
    }
}